<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        // 核心算法：利用charAt()遍历这个字符串
        // 把每个字符都存储给对象，如果对象没有该属性，就为1，存在了就+1
        // 遍历对象，得到最大值和该字符
        var str = 'sdkadhbkadhsakjbsdfe';
        var o = {};
        for (var i = 0; i < str.length; i++) {
            var chars = str.charAt(i);
            if (o[chars]) {
                o[chars]++;
            } else {
                o[chars] = 1;
            }
        }
        // 2、遍历对象
        var max = 0;
        var ch = ''
        for (var key in o) {
            if (o[key] > max) {
                max = o[key];
                ch = k;
            }
        }
        console.log(max);
        console.log(ch);
    </script>
</head>

<body>

</body>

</html>